﻿@using EmployeeLeaveSystem.Shared;
@using EmployeeLeaveSystem.Shared.Models;
@inject IMessageService _MessageService;
@inject HttpClient _HttpClient;

<h5>我的薪水历史记录</h5>
<Descriptions Title="相关细则一览" Bordered Column="@column">
    <DescriptionsItem Title="编号">
        @salaryInfo.Id
    </DescriptionsItem>
    <DescriptionsItem Title="申请人编号">
        @salaryInfo.StaffId
    </DescriptionsItem>
    <DescriptionsItem Title="申请人姓名">
        @salaryInfo.Staff?.Name
    </DescriptionsItem>
    <DescriptionsItem Title="员工上司对象">
        @salaryInfo.Staff?.UpperStaff?.Name
    </DescriptionsItem>
    <DescriptionsItem Title="年份和月份">
        @salaryInfo.Year | @salaryInfo.Month
    </DescriptionsItem>
    <DescriptionsItem Title="基础薪水">
        @salaryInfo.BaseSalary
    </DescriptionsItem>
    <DescriptionsItem Title="奖励薪水">
        @salaryInfo.AddLiveSalary
    </DescriptionsItem>
    <DescriptionsItem Title="扣除薪水">
        @salaryInfo.CutOffSalary
    </DescriptionsItem>
    <DescriptionsItem Title="浮动薪水">
        @salaryInfo.CustomSalary
    </DescriptionsItem>
    <DescriptionsItem Title="原因">
        @salaryInfo.Reason
    </DescriptionsItem>
    <DescriptionsItem Title="最终薪水">
        @(salaryInfo.BaseSalary + salaryInfo.AddLiveSalary - salaryInfo.CutOffSalary)
    </DescriptionsItem>
</Descriptions>
@code {
    [Parameter]
    public int Id { get; set; }
    SalaryInfo salaryInfo = new();
    protected override async Task OnParametersSetAsync() {
        try {
            salaryInfo = await _HttpClient.GetFromJsonAsync<SalaryInfo>($"api/Salary/GetInfoById?id={Id}");
        }
        catch (Exception ex) {
            _MessageService.Error("获取信息失败");
            App._appHandle.NoticeWithIcon(NotificationType.Error, "失败", ex.Message);
        }
        InvokeAsync(StateHasChanged);
        _MessageService.Success("刷新数据成功");
    }
    // 样式布局
    private Dictionary<string, int> column = new Dictionary<string, int> {
            { "xxl", 3 },
            { "xl", 3},
            { "lg", 2},
            { "md", 2},
            { "sm", 1},
            { "xs", 1}
        };

}
